// loading ts

import {nextTick} from 'vue';
import '/@/theme/loading.scss';

// 全局loading 
//start 创建loading
//done 移除loading

export const NextLoading ={
    start:() =>{
        const bodys:Element = document.body;
        const div = <HTMLElement>document.createElement('div');
        div.setAttribute('calss','loading-next');
        const htmls = `
          <div class="loading-next-box">
            <div class="loading-next-wrap">
                <div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
				<div class="loading-next-box-item"></div>
            </div>
          </div>
        `;
        div.innerHTML = htmls;
        bodys.insertBefore(div,bodys.childNodes[0]);
        window.nextLoading = true;
    },
    done:() =>{
        nextTick(() =>{
            window.nextLoading = false;
            const el = <HTMLElement>document.querySelector('.loading-next');
            el?.parentNode?.removeChild(el);
        })
    }
}